package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.errors.BusinessException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionsHandler {
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result customGenericExceptionHandler(BusinessException exception){
        return new Result(false,exception.getMsg());
    }
}
